$(function() {

	init();

	$("#year").change(function() {

		init();
	});

	$("#month").change(function() {
		init();
	});
});

function init() {

	var year = $("#year").val();
	var month = $("#month").val();

	var yearmonth = "";

	if (year !== '' && month !== '') {
		yearmonth = year +'-'+ month;
	}else if(year !== '')
	{
		yearmonth = year+'-';
	}

	// if (year == '' || month == '') {
	// 	$("#date_text").text("全部账单");
	// } else {
	// 	$("#date_text").text(yearmonth);
	// }



	$.get('/wx/property/bill/data', {
		'yearmonth': yearmonth
	}, function(result) {

		var list = '<div class="bill_title"><span>全部账单</span><i></i></div>';
		var yearmonth = "";
		var resultT = result;
		if (result.length > 0) {
			for (var i in result) {

				if (result[i].yearmonth +'' != yearmonth) {
					yearmonth = result[i].yearmonth ;
					list += '<div class="bill_time">';
					list += result[i].yearmonth;
					list += '</div>';
				}

				list += '<ul class="pay_list">';
				if(result[i].status == '已缴')
					list += '<li><span style="color:green">' + result[i].status + '</span><b>' + result[i].project + '</b><b>￥' + result[i].qsAccount + '</b></li>';
				else
					list += '<li><span>' + result[i].status + '</span><b>' + result[i].project + '</b><b>￥' + result[i].qsAccount + '</b></li>';
				list += '</ul>';

			}


		} else {

			list += '<div class="am-u-sm-12" style="margin:0px;background: white;padding:10px;text-align:center;">无账单数据...</div>';
		}

		$("#bill_list").html(list);

	});

}

